home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / bas_int1.zip / CHGDRV.BAS < prev    next >
BASIC Source File  |  1991-05-26  |  2KB  |  45 lines

  1. '====================================================================
  2. '   Quick Basic Forum
  3. '   Date : 23-Apr-91
  4. '   From : Robert Lee
  5. 'Subject : CHDRV IN QB45
  6. '
  7. 'Although PDS 7.X includes the CHDRV command, QB 4.5 does not. The
  8. 'easiest way to do a change drive is to call the 0Eh function of the
  9. 'DOS services interrupt (21h). To do this, load QB with the QB.QLB
  10. 'quick library and include the following routines in your program.
  11. 'The FUNCTION GetDrive$ returns the current drive letter, and the
  12. 'SUB ChgDrive() sets the current to drive to the calling argument.
  13. '====================================================================
  14.  
  15. '$INCLUDE: 'QB.BI'
  16. DECLARE FUNCTION GetDrive$ ()
  17. DECLARE SUB ChgDrive (Drive AS STRING)
  18.  
  19. SUB ChgDrive (Drive AS STRING)    ' Set the current drive letter
  20. DIM REGS AS RegType               ' Type declared in QB.BI
  21. AH = &H0E                         ' Function number set in AH
  22. AL = &H00                         ' AL is not set to anything
  23. REGS.AX = AH*&H100 + AL           ' AH is high 8 bits, AL is low 8
  24. DH = &H00                         ' DH is not set to anything
  25. DL = ASC(UCASE$(Drive)) - 65      ' DL is set to the drive number
  26.                                   ' A=0, B=1, C=2, etc.
  27. REGS.DX = DH*&H100 + DL
  28. CALL Interrupt(&H21, REGS, REGS)  ' Call the DOS services int
  29. AL = REGS.AX MOD &H100            ' Set AL to low 8 bits of AX
  30.                                   ' AL returns the max number of
  31.                                   ' drives available 25=Z, etc
  32. END SUB
  33.  
  34. FUNCTION GetDrive$                ' Get the current drive letter
  35. DIM REGS AS RegType               ' Type declared in QB.BI
  36. AH = &H19                         ' Function number
  37. AL = &H00                         ' AL is not set to anything
  38. REGS.AX = AH * &H100 + AL         ' AL is 16 bit
  39. CALL Interrupt(&H21, REGS, REGS)  ' Call the DOS services int
  40. AL = REGS.AX MOD &H100            ' AL is low 8 bits of AX
  41. GetDrive$ = CHR$(AL + 65)         ' AL returns the drive number
  42.                                   ' convert to ASCII with 0=A
  43. END FUNCTION
  44.  
  45.